package admin.forms;

import java.util.TreeMap;

import javax.servlet.http.HttpServletRequest;

import admin.data.CategoryData;

import models.CategoryModel;


public class CategoryForm {
	public TreeMap checkValid(HttpServletRequest request, CategoryModel category) {
		TreeMap form = new TreeMap();
		TreeMap check = new TreeMap();
		
		CategoryData categoryData = new CategoryData();
		
		String categoryId = (String) request.getParameter("categoryId");
		String name = (String) request.getParameter("name");
		String alias = (String) request.getParameter("alias");
		
		category.setCategoryId(categoryId);
		
		if (name == null || name.isEmpty()) {
			check.put("name", "Bạn chưa nhập thông tin tên.");
			category.setName("");
		} else {
			category.setName(name);
		}
		
		if (alias != null) {
			category.setAlias(alias);
		}
		
		form.put("checkValid", check);
		form.put("category", category);
		
		return form;
	}
}
